package cn.iocoder.yudao.module.member.controller.app.order;

import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.ipa.MbUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.member.controller.app.order.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.order.MemberCertificateOrderDo;
import cn.iocoder.yudao.module.member.dal.mysql.order.MemberCertificateOrderMapper;
import cn.iocoder.yudao.module.member.service.order.CertificateOrderService;
import cn.iocoder.yudao.module.member.service.order.HuaYangV2Strategy;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Base64;
import java.util.List;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.USER_CERTIFICATE_ORDER_NOT_SELECT;

@Tag(name = "用户 App - 证书管理")
@RestController
@RequestMapping("/member/certificate")
@Validated
public class CertificateOrderController {

    @Resource
    private CertificateOrderService certificateOrderService;
    @Resource
    private FileApi fileApi;
    @Resource
    private HuaYangV2Strategy huaYangV2Strategy;
    @Resource
    private MemberCertificateOrderMapper memberCertificateOrderMapper;

    @PostMapping("/createOrder")
    @Operation(summary = "创建订单")
    @PreAuthenticated
    public CommonResult<AppMemberCertificateOrderVo> createOrder(@Valid @RequestBody AppMemberCertificateOrderVo appOrderVo) throws Exception {
        MemberCertificateOrderDo order = certificateOrderService.createOrder(appOrderVo);
        return success(BeanUtils.toBean(order,AppMemberCertificateOrderVo.class));
    }

    @PostMapping("/page")
    @Operation(summary = "获得用户设备记录分页")
    @PreAuthenticated
    public CommonResult<PageResult<AppMemberCertifiOrderRecordRespVO>> getPointRecordPage(
            @Valid @RequestBody AppMemberCertificateOrderRecordPageReqVO pageReqVO) {
        PageResult<MemberCertificateOrderDo> pageResult = certificateOrderService.getCertifiOrdeRecordPage(getLoginUserId(), pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppMemberCertifiOrderRecordRespVO.class));
    }
    @PostMapping("/updateOrderLink")
    @Operation(summary = "修改设备证书地址")
    @PreAuthenticated
    public CommonResult<Boolean> updateOrderLink(@Valid @RequestBody UpdateReqVO updateReqVO) {
        certificateOrderService.updateOrderLink(updateReqVO);
        return success(true);
    }

    @PostMapping("/updateOrderRemark")
    @Operation(summary = "修改备注信息")
    @PreAuthenticated
    public CommonResult<Boolean> updateOrderRemark(@Valid @RequestBody UpdateRemarkReqVO updateRemarkReqVO) {
        certificateOrderService.updateOrderRemark(updateRemarkReqVO);
        return success(true);
    }


    @GetMapping("/deleteById")
    @Operation(summary = "删除设备")
    @PreAuthenticated
    public CommonResult<Boolean> deleteById(@Param("id") Long id) throws Exception {
        MemberCertificateOrderDo orderDo = certificateOrderService.getById(id);

        certificateOrderService.deleteById(id);

        if(StrUtil.isNotBlank(orderDo.getP12Url())){
            fileApi.deleteFile(Long.valueOf(CharSequenceUtil.subAfter(orderDo.getP12Url(), "/get/", false)));
        }
        if(StrUtil.isNotBlank(orderDo.getMpUrl())){
            fileApi.deleteFile(Long.valueOf(CharSequenceUtil.subAfter(orderDo.getMpUrl(), "/get/", false)));
        }
        return success(true);
    }

    //下单询价


    @PostMapping("/queryPrice")
    @Operation(summary = "询价")
    @PreAuthenticated
    public CommonResult<BigDecimal> queryPrice(@Valid @RequestBody AppMemberCertificateOrderVo appOrderVo) throws Exception {
        return success(certificateOrderService.queryPrice(appOrderVo));
    }

    /**
     * 用户单独价格
     * @param appOrderVo
     * @return
     * @throws Exception
     */
    @PostMapping("/queryMyPrice")
    @Operation(summary = "用户单独价格")
    @PreAuthenticated
    public CommonResult<BigDecimal> queryMyPrice(@Valid @RequestBody AppMemberCertificateOrderVo appOrderVo) throws Exception {
        return success(certificateOrderService.queryMyPrice(appOrderVo));
    }
    @GetMapping("/downloadCertificate")
    @Operation(summary = "下载证书和描述文件")
    public void downloadCertificate(HttpServletRequest request, HttpServletResponse response) throws Exception {
        certificateOrderService.downloadCertificate(request, response);
    }

    @GetMapping("/downloadCertificateCheck")
    @Operation(summary = "检查")
    public void downloadCertificateCheck(HttpServletRequest request, HttpServletResponse response) throws Exception {
        certificateOrderService.downloadCertificateCheck(request, response);
    }

    @GetMapping("/getByUdid")
    @Operation(summary = "根据设备 udid 获得设备信息")
    public CommonResult<AppMemberCertificateOrderVo> getByUdid(@RequestParam("udid") String udid,@RequestParam("userId") Long userId) throws Exception {
        MemberCertificateOrderDo order = certificateOrderService.getByUdidAndUserId(udid,userId);
        return success(BeanUtils.toBean(order,AppMemberCertificateOrderVo.class));
    }
    @PostMapping("/test")
    public void test() throws Exception {
String string = "MIJEcwYJKoZIhvcNAQcCoIJEZDCCRGACAQExCzAJBgUrDgMCGgUAMII0gAYJKoZIhvcNAQcBoII0cQSCNG08P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCI/Pgo8IURPQ1RZUEUgcGxpc3QgUFVCTElDICItLy9BcHBsZS8vRFREIFBMSVNUIDEuMC8vRU4iICJodHRwOi8vd3d3LmFwcGxlLmNvbS9EVERzL1Byb3BlcnR5TGlzdC0xLjAuZHRkIj4KPHBsaXN0IHZlcnNpb249IjEuMCI+CjxkaWN0PgoJPGtleT5BcHBJRE5hbWU8L2tleT4KCTxzdHJ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ChTCCAoECAQEwfzBzMS0wKwYDVQQDDCRBcHBsZSBpUGhvbmUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUwIIPVn4N+rR2J8wCQYFKw4DAhoFAKCB3DAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yNTAzMjUwODEwNTdaMCMGCSqGSIb3DQEJBDEWBBQWU2g3u6rabx1by0zBoxBosma0mDApBgkqhkiG9w0BCTQxHDAaMAkGBSsOAwIaBQChDQYJKoZIhvcNAQEBBQAwUgYJKoZIhvcNAQkPMUUwQzAKBggqhkiG9w0DBzAOBggqhkiG9w0DAgICAIAwDQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZIhvcNAwICASgwDQYJKoZIhvcNAQEBBQAEggEAJTyLk70Ty/zgBDL3IVGUkrCGsKgLEHojhEpMd52yEd7VCU2vQQFhtJ1Fc0/HrY3d13YgfGuqtTAxFf7CrDnBX3ysPmSVa1wTqRICLlYzK43AZ1mW+fLHG6Aj8lW6u5A2+0RtxTVH3N76NwMedXmYR0PEOc5JXsuVszRCpCiJoR/WXKfvnCA1q0RBhQ8nKIxdigUn5J67FBNK/6pTg12Gp0oF1G0q67RmkBVl3uC4jE55m/X6KanUti/IIHz0JadpoRgJdczAjEelrtBDzaQUl9+mhVCNQT2TGt/hLdHvyGlYctUDlB82YcTbyZBHZkMKifaLtaxsFe0phA/ejTZGSg==";
        byte[] p12Bytes = Base64.getDecoder().decode(string.replaceAll("\\s", ""));
        // 2. 写入文件
        String outputPath = "certificate_test.p12";
        try (FileOutputStream fos = new FileOutputStream(outputPath)) {
            fos.write(p12Bytes);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        MbUtil.parseProvisionFile(outputPath);
        System.out.println("sss");
    }


    /**
     * 查询yon
     * @param userId
     * @param udid
     * @return
     */
    @GetMapping("/getListByUserAndUdid")
    @Operation(summary = "根据用户id以及udid查询设备")
    public CommonResult<List<AppMemberCertifiOrderRecordRespVO>> getListByUserAndUdid(
            @Param("userId") Long userId ,@Param("udid") String udid ) {
        List<MemberCertificateOrderDo> pageResult = certificateOrderService.getListByUserAndUdid(userId, udid);
        return success(BeanUtils.toBean(pageResult, AppMemberCertifiOrderRecordRespVO.class));
    }


    /**
     * 用户自己上传设备
     * @param updateReqVO
     * @return
     */
    @PostMapping("/loadDevice")
    @Operation(summary = "用户自己上传设备")
    @PreAuthenticated
    public CommonResult<Boolean> loadDevice(
            @Valid @RequestBody UpdateReqVO updateReqVO) throws Exception {
    certificateOrderService.loadDevice(updateReqVO);
        return success(true);
    }

    @GetMapping("/getById")
    @Operation(summary = "创建订单")
    @PreAuthenticated
    public CommonResult<AppMemberCertificateOrderVo> getById(@Param("id") Long id)  {
        MemberCertificateOrderDo order = certificateOrderService.getById(id);
        return success(BeanUtils.toBean(order,AppMemberCertificateOrderVo.class));
    }

//    @PostMapping("/createOrderByOther")
//    @Operation(summary = "创建订单")
//    public CommonResult<AppMemberCertificateOrderVo> createOrderByOther(@Valid @RequestBody AppMemberCertificateOrderVo appOrderVo) throws Exception {
//        MemberCertificateOrderDo order = certificateOrderService.createOrderByOther(appOrderVo);
//        return success(BeanUtils.toBean(order,AppMemberCertificateOrderVo.class));
//    }

    @PostMapping("/test1")
    @Operation(summary = "定时任务跑一部系统文件")
    public void createOrderByOther() {
        certificateOrderService.excuteSignTask();
    }


//    /**
//     * 查询第三方数据的接口
//     */
//    @PostMapping("/findThirdCertificate")
//    @Operation(summary = "查询第三方数据的接口")
//    public void findThirdCertificate() {
//        certificateOrderService.findThirdCertificate();
//    }

    @GetMapping("/mplist")
    @Operation(summary = "获取描述文件列表")
    @PreAuthenticated
    public CommonResult<List<HauYangMpThirdReturnVo>> mplist(@RequestParam("id") Long id) throws Exception {
        MemberCertificateOrderDo memberCertificateOrderDo = memberCertificateOrderMapper.selectById(id);
        if (memberCertificateOrderDo==null){
            throw exception(USER_CERTIFICATE_ORDER_NOT_SELECT);

        }
        List<HauYangMpThirdReturnVo> list = huaYangV2Strategy.listMp(memberCertificateOrderDo);
        return success(list);
    }
    @GetMapping("/changeMp")
    @Operation(summary = "切换描述文件")
    @PreAuthenticated
    public void changeMp(@RequestParam("id") Long id,@RequestParam("bundleId") String bundleId) throws Exception {
        MemberCertificateOrderDo memberCertificateOrderDo = memberCertificateOrderMapper.selectById(id);
        if (memberCertificateOrderDo==null){
            throw exception(USER_CERTIFICATE_ORDER_NOT_SELECT);

        }
        huaYangV2Strategy.changeMp(memberCertificateOrderDo,bundleId);
    }

}
